﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;

namespace EasyTest {

    /// <summary>
    /// Button object
    /// </summary>
    public class Button : IElement {
        /// <summary>
        /// Create new Button object.
        /// </summary>
        /// <param name="findBy">HTML text to identify and find elements within a document.</param>
        public Button(string findBy) {
            FindBy = findBy;
            Focus = new Focus();
        }
        /// <summary>
        /// Create new Button object.
        /// </summary>
        /// <param name="findBy">HTML text to identify and find elements within a document.</param>
        /// <param name="focus">Document container with controls to search for.</param>
        public Button(string findBy, Focus focus)
            : this(findBy) {
            Focus = focus;
        }

        /// <summary>
        /// Create new Button object.
        /// </summary>
        /// <param name="findBy">HTML text to identify and find elements within a document.</param>
        /// <param name="element">Parent Element that the button is located on.</param>
        /// <param name="focus">Document container with controls to search for.</param>
        public Button(string findBy, IElement element, Focus focus)
            : this(findBy, focus) {
            ParentElement = element;
        }

        /// <summary>
        /// Execute the Click() event for this button.
        /// </summary>
        public override void Click() {
            GoTo();
            Action.Click(FindBy);
        }
        public bool IsDisabled()
        {
            GoTo();
            return Action.IsDisabled(FindBy);
        }
        
    }
}
